package com.epalmpay.controller.channel.ys.profit;

import com.epalmpay.commom.BaseController;
import com.epalmpay.exception.ApplicationException;
import com.epalmpay.status.Rescode;
import com.epalmpay.dto.yunliu.profit.PolicyProfitListInDTO;
import com.epalmpay.dto.yunliu.profit.YsProfitOutDTO;
import com.epalmpay.service.ys.profit.IYsProfitService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@RequestMapping(value="/merchant/ys/profit")
public class PolicyProfitController extends BaseController {
     
	@Resource
	private IYsProfitService ysProfitService;

	@RequestMapping(value="/policyProfitList")
	@ResponseBody
	public YsProfitOutDTO policyProfitList(@RequestBody PolicyProfitListInDTO inDTO){
		YsProfitOutDTO outDTO = new YsProfitOutDTO();
		try {
			outDTO = ysProfitService.getPolicyProfitList(inDTO);
			outDTO.setErrorCode(Rescode.SUCCESS, "处理成功");
			return outDTO;
		} catch (ApplicationException ae) {
			outDTO.setErrorCode(ae.errCode, ae.errMsg);
			ae.printStackTrace();
			logger.error(ae);
		}
		catch (Exception e) {
			outDTO.setErrorCode(Rescode.DEFAULT_PREFIX, "处理出现异常");
			e.printStackTrace();
			logger.error(e);
		}
		return outDTO;
	}

	@RequestMapping(value="/policyProfitMonthList")
	@ResponseBody
	public YsProfitOutDTO policyProfitMonthList(@RequestBody PolicyProfitListInDTO inDTO){
		YsProfitOutDTO outDTO = new YsProfitOutDTO();
		try {
			outDTO = ysProfitService.getPolicyProfitMonthList(inDTO);
			outDTO.setErrorCode(Rescode.SUCCESS, "处理成功");
			return outDTO;
		} catch (ApplicationException ae) {
			outDTO.setErrorCode(ae.errCode, ae.errMsg);
			ae.printStackTrace();
			logger.error(ae);
		}
		catch (Exception e) {
			outDTO.setErrorCode(Rescode.DEFAULT_PREFIX, "处理出现异常");
			e.printStackTrace();
			logger.error(e);
		}
		return outDTO;
	}

	@RequestMapping(value="/policyProfitDayList")
	@ResponseBody
	public YsProfitOutDTO policyProfitDayList(@RequestBody PolicyProfitListInDTO inDTO){
		YsProfitOutDTO outDTO = new YsProfitOutDTO();
		try {
			outDTO = ysProfitService.getPolicyProfitDayList(inDTO);
			outDTO.setErrorCode(Rescode.SUCCESS, "处理成功");
			return outDTO;
		} catch (ApplicationException ae) {
			outDTO.setErrorCode(ae.errCode, ae.errMsg);
			ae.printStackTrace();
			logger.error(ae);
		}
		catch (Exception e) {
			outDTO.setErrorCode(Rescode.DEFAULT_PREFIX, "处理出现异常");
			e.printStackTrace();
			logger.error(e);
		}
		return outDTO;
	}
}
